;
(function() {
	var role = require("./role");
	var BusCon = require("../../core/bus/_con");
	var UserCon = require("../../core/user/_con");
	var GoodsCon = require("../../core/goods/_con");
	var AchCon = require("../../core/ach/_con");
	var CommentCon = require("../../core/comment/_con");
	var EvalCon = require("../../core/eval/_con");
	var db = require("../../core/db/index");
	var config = require("../../core/_include/config");
	var ResponObj = require("../_include/responObj");

	module.exports = {
		prefix: "/user/eval",
		get: {
			//获取自己的评价
			"/": function() {
				var user = role.getUser(this);
				var query = this.request.query;
				var evaluations = user.getEvaluations(query.num, query.page);
				this.body = ResponObj("json", evaluations);
			},
			// "/byId/:eval_id":function () {
			// 	var user = role.getUser(this);
			// 	var eval_id = this.params.eval_id;

			// },
			// "/canEvalutionAble/:goods_id": function() {
			// 	var user = role.getUser(this);
			// 	var goods_id = this.params.goods_id;
			// 	this.body = ResponObj("json", {
			// 		can_evaluation_able: user.toEvaluation(goods_id)
			// 	});
			// },
			"/with_page_info": function() {
				var user = role.getUser(this);
				var query = this.request.query;
				var info = user.getEvaluations_PageInfo(query.num, query.page);
				this.body = ResponObj("json", info);
			}
		},
		post: {
			// "/as_eval/:goods_id": function() {
			// 	var user = role.getUser(this);
			// 	var body = this.request.body;
			// 	var goods_id = this.params.goods_id;
			// 	var eval_id = user.addEvaluation(
			// 		goods_id,
			// 		body.star_num,
			// 		body.content,
			// 		body.isAny
			// 	);
			// 	this.body = ResponObj("json", EvalCon.get(eval_id).getDetail());
			// },
			"/as_comment": function() {
				var user = role.getUser(this);
				var body = this.request.body;
				var reply_id = body.reply_id;
				var content = body.content;
				if (!(reply_id && content)) {
					throwCusError("参数错误")
				}
				var comment_id = user.addComment(reply_id, content /*,isAny*/ ) //商家不可匿名
				this.body = ResponObj("json", CommentCon.get(comment_id).getDetail())
			}
		}
	}
}());